home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / C / READLN.H < prev   
Text File  |  1997-01-09  |  1KB  |  66 lines

  1. // used by PASM and iASM
  2.  
  3. void readln(void) {
  4.   byte a=0;
  5.   word p=0;
  6.   word t;
  7.   byte f1,f2;
  8.  
  9.   #ifdef DEBUG3
  10.     printf("(readon)");
  11.   #endif
  12.   while (a!=10) {
  13.     if (!bufis[ch]) {
  14.       t=read(h,bufin[ch],bufsiz);
  15.       bufis[ch]=t;
  16.       if (!t) {
  17.         EOFF[ch]=1;
  18.         buf[p]=0;
  19.   #ifdef DEBUG3
  20.     printf("(readoff)");
  21.   #endif
  22.         return;
  23.       }
  24.       bufip[ch]=0;
  25.     }
  26.     a=*(bufin[ch]+(bufip[ch]++));
  27.     bufis[ch]--;
  28.     buf[p++]=a;
  29.     if (p>200) error("Line too long (200)");
  30.     if (a==13) buf[p-1]=0;
  31.   }
  32.   buf[p]=0;
  33.   //convert 9 to 32
  34.   f1=0;  //inside ''
  35.   f2=0;  //inside ""
  36.   p=0;
  37.   while (buf[p]) {
  38.     a=buf[p];
  39. #ifdef IASM
  40.     if (f1) {
  41.       if ( a=='\'' ) {
  42.         if ( buf[p+1] =='\'') {p+=2;continue;}
  43.         f1=0;p++;continue;
  44.       }
  45.     }
  46. #endif
  47.     if (f2) {
  48.       if ( a=='\"' ) {
  49.         if ( buf[p+1] =='\"') {p+=2;continue;}
  50.         f2=0;p++;continue;
  51.       }
  52.     }
  53.     if (a==9) if ((!f1)&&(!f2)) {buf[p++]=32;continue;}  //convert 9 to 32
  54.     if ((f1) || (f2)) {p++;continue;}
  55. #ifdef IASM
  56.     if ( a=='\'' ) f1=1;
  57. #endif
  58.     if ( a=='\"' ) f2=1;
  59.     p++;
  60.   }
  61.   bufln[ch]++;
  62.   #ifdef DEBUG3
  63.     printf("(readoff)");
  64.   #endif
  65. }
  66.